package com.shop.mms_client.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.shop.mms_client.R;
import com.shop.mms_client.model.Message;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseMessageFragment extends Fragment {
    protected RecyclerView recyclerView;
    protected MessageAdapter adapter;
    protected List<Message> messageList = new ArrayList<>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_message_list, container, false);
        recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new MessageAdapter(messageList);
        recyclerView.setAdapter(adapter);
        return view;
    }

    protected void updateMessages(List<Message> messages) {
        messageList.clear();
        messageList.addAll(messages);
        adapter.notifyDataSetChanged();
    }
} 